<?
require("class/configuration.class.php");
//Konfiguration laden
$serverId=$_SESSION[server_Id];
if($_SESSION[user][Rang]<9 AND !in_array($serverId, $_SESSION[user][Rundenadmin])) exit;
if($serverId==0){
    echo "ungültige Serverid. Vermutlich ist noch ein weiteres Browserfenster offen.";
	exit;
}
echo "<h2>Server #$serverId konfigurieren</h2>";
$main=new configuration("conf/main.conf.php");
$main->addConfigFile("conf/server/server-$serverId.conf.php");
$server=new configuration("conf/server/default.conf.php");
$server->addConfigFile("conf/server/server-$serverId.conf.php");
$builds=new configuration("conf/build.conf.php", "config_bau");
$builds->addConfigFile("conf/server/server-$serverId.conf.php");

//Änderungen speichern
if(isset($_POST[main]))
{
    //konfiguration speichern
    $main->update($_POST[main]);
	$server->update($_POST[server]);
	$builds->update($_POST[builds]);
    //config file erstellen
    $config="<?\n".$main->export().$server->export().$builds->export()."?>";
	file_put_contents("conf/server/server-$serverId.conf.php",$config);
}	
echo "
<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
  <input type=\"hidden\" name=\"page\" value=\"$_SESSION[page]\" />
  <input type=\"hidden\" name=\"adminpage\" value=\"$_SESSION[adminpage]\" />
  ";
  echo "<h2>Main configuration</h2>";
  $main->editor("main");
  echo "<h2>Server specific configuration</h2>";
  $server->editor("server");
  echo "<h2>Build configurations</h2>";
  $builds->editor("builds");
  echo "
  <input type=\"submit\" value=\"Save changes to specific server configuration\" />
</form>";